package com.ys.ffms.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Description: swagger配置
 * @PROJECT_NAME: ffmsService
 * @DESCRIPTION:
 * @USER: lin
 * @DATE: 2022/2/12 14:36
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    /**
     * swagger docket实例
     * @return
     */
    @Bean
    public Docket docket(){
        return  new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .enable(true)              //是否激活swagger,如果是正式环境下，请把他设置为false
                .groupName("家庭财务管理系统")          //分组，可以设置多个docket
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.ys.ffms.controller"))
                .paths(PathSelectors.any())
                .build();
    }


    public ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("家庭财务")
                .description("接口文档")
                .version("1.0")
                .termsOfServiceUrl("termsOfServiceUrl")
                .contact(new Contact("小邓","http://localhost:3271/","2100806393@QQ.com"))
                .build();
    }
//    下面的是默认配置 apiInfo.default
//    static {
//        DEFAULT = new ApiInfo("Api Documentation", "Api Documentation", "1.0", "urn:tos", DEFAULT_CONTACT, "Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0", new ArrayList());
//    }
}


